﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using RRTWSEntityDSD.Dao;
using RRTWSEntityDSD.Dominio;

namespace RRTWSDSD.ServiceEntidad
{
    /// <summary>
    /// Summary description for ClienteServices
    /// </summary>
    [WebService(Namespace = "http://rtt.edu.upc.com.pe/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    
    public class ClienteServices : System.Web.Services.WebService
    {

        private static ClienteDAO clienteDAO = new ClienteDAO();

        [WebMethod]
        public Cliente getCliente(string uuid)
        {
            if (uuid == null)
            {
                throw new NullReferenceException("valor vacio");
            }
            Cliente c = clienteDAO.getClienteByUuID(uuid);
            if (c == null)
            {
                throw new NullReferenceException("No existe cliente");
            }
            return c;
        }

        [WebMethod]
        public Cliente crearNuevoCliente(string uuid, string dni, string apellidos, string nombres)
        {
            if (uuid == null || dni == null || nombres == null || apellidos == null)
            {
                throw new NullReferenceException("Valores vacios");
            }
            return clienteDAO.insert(uuid, dni, apellidos, nombres);
        }

    }
}
